package com.jeesite.modules.topiam.service;

import com.jeesite.common.config.Global;
import com.jeesite.modules.topiam.oauth.AuthTopIamRequest;
import me.zhyd.oauth.config.AuthConfig;
import me.zhyd.oauth.model.AuthUser;

import java.util.ArrayList;
import java.util.List;

/**
 * @author SanLi
 * Created by support@topiam.cn on  2023/8/30 21:23
 */
public interface TopIamOauth2Service {

    /**
     * 换取系统用户ID
     *
     * @param authUser {@link AuthUser}
     * @return {@link Boolean}
     */
    String getSysUserCode(AuthUser authUser);

    default AuthTopIamRequest getAuthTopIamRequest() {
        List<String> scopes = new ArrayList<>();
        scopes.add("profile");
        scopes.add("openid");
        return new AuthTopIamRequest(AuthConfig.builder()
                .clientId(Global.getProperty("oauth2.topiam.clientId"))
                .clientSecret(Global.getProperty("oauth2.topiam.clientSecret"))
                .redirectUri(Global.getProperty("oauth2.topiam.redirectUri"))
                .scopes(scopes)
                .build());
    }
}
